﻿using System.Data.Entity;

namespace FlexPlatform.Shared.Configuration
{
    using FlexPlatform.Shared.DataModel;

    /// <summary>
    /// Represents a temporary workspace, holding specific settings and data context.
    /// </summary>
    public interface IWorkspace
    {
        /// <summary>
        /// Sets the working data context.
        /// </summary>
        /// <typeparam name="DbContextType"> The data context's type</typeparam>
        /// <param name="DataContext"> The data context.</param>
        void SetDataContext<DbContextType>(DbContextType DataContext) where DbContextType : DbContext;
        
        /// <summary>
        /// Retrieves the current data context stored in this workspace.
        /// </summary>
        /// <returns> The data context associated with this workspace.</returns>
        DbContext GetDataContext();

        /// <summary>
        /// Creates a data entity and associates it with this workspace.
        /// </summary>
        /// <typeparam name="T"> The Data Entity type.</typeparam>
        /// <returns> A new instance of <paramref name="T"/>.</returns>
        T CreateDbEntity<T>() where T : IDbEntity, new();
    }
}
